home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / drcpas10.zip / TIMER.PAS < prev    next >
Pascal/Delphi Source File  |  1992-11-17  |  979b  |  45 lines

  1. Unit Timer;
  2. {$A+,B-,D-,F-,I-,L-,O-,R-,S-,V-}
  3.  
  4. (* by David R. Conrad, for Turbo Pascal 5.5
  5.  
  6.    This code is not copyrighted, you may use it freely.
  7.    There are no guarantees, either expressed or implied,
  8.    as to either merchantability or fitness for a particular
  9.    purpose.  The author's liability is limited to the amount
  10.    you paid for it.
  11.  
  12.    David R. Conrad, 17 Nov 92
  13.    David_Conrad@mts.cc.wayne.edu
  14.    dave@michigan.com
  15. *)
  16.  
  17. Interface
  18.  
  19. type
  20. {$IFOPT N+}
  21.   float = double;
  22. {$ELSE}
  23.   float = real;
  24. {$ENDIF}
  25.  
  26. const
  27.   TIX_PER_SECOND : float = 1193180 / 65536;
  28.   TIX_PER_DAY = $1800B0;
  29.  
  30. var
  31.   ClockTix : Longint absolute $0040:$006C;
  32.  
  33. function difftix (start, finish : longint) : longint;
  34.  
  35. Implementation
  36.  
  37. function difftix (start, finish : longint) : longint;
  38. (* difference between to clock ticks; handles midnight wraparound *)
  39. begin
  40.   if finish < start then finish := finish + TIX_PER_DAY;
  41.   difftix := finish - start;
  42. end;
  43.  
  44. End.
  45.